package eerbaar.v2.app.forge;

import eerbaar.elements.IElement;
import eerbaar.elements.extension.ElementFactory;
import eerbaar.game.IGame;
import eerbaar.level.ILevel;
import eerbaar.level.LevelFactory;
import eerbaar.message.lib.DisplayMessageMsg;
import eerbaar.message.lib.LevelChangeMsg;
import eerbaar.position.IPosition;
import eerbaar.position.PositionFactory;
import eerbaar.shared.message.MsgHelper;
import eerbaar.v2.app.GameHelper;

public class LevelForge {

    public LevelForge() {
        //
    }

    public void start() {

        IGame game = GameHelper.getGame();

        ILevel level = LevelFactory.create(2, "Second Level");
        IPosition max = PositionFactory.createPosition(9, 9);
        IElement bone = ElementFactory.createWithRandomPosition("bone", max);
        game.getArea().addElement(bone);

        game.setLevel(level);

        MsgHelper.sendMsg(LevelChangeMsg.class, new LevelChangeMsg());

        String goal = game.getLevel().getGoal();
        DisplayMessageMsg msg = new DisplayMessageMsg(goal);
        MsgHelper.sendMsg(DisplayMessageMsg.class, msg);

        GameHelper.setGame(game);
    }

}
